new Vue({
    el:"#app",
    data:{
        userList:[],
        user:{
            username:"",
            password:"",
            sex:"",
            age:"",
            email:""
        }
    },
    methods:{
        //执行修改
        update(){
            axios.post("/vuejsDemo/user/update.do",this.user).then((response)=>{
                this.findAll();
            })
        },
        findById(id){
            axios.get("/vuejsDemo/user/findById.do?id="+id).then((response)=>{
               //给user赋值
                this.user= response.data;

               //显示编辑窗口
               $("#myModal").modal("show");

            }).catch((ex)=>{
                console.log(ex)
            })
        },
       findAll(){
            //向user/findAll.do发放ajax请求
            axios.get("/vuejsDemo/user/findAll.do").then((response)=>{
                this.userList= response.data
            }).catch((error)=>{
                console.log(error)
            })
        }

    },
    created(){
            this.findAll();
    }
});